<?php
declare (strict_types = 1);

namespace app\api\middleware;

use app\api\server\Token;

class Check
{
    /**
     *
     * 处理请求
     *
     * @param \think\Request $request
     * @param \Closure       $next
     * @return Response
     */
    public function handle($request, \Closure $next)
    {
        // 需要验证用户是否登录
        $uid = Token::verifyToken();
        if ($uid) {
            $request->uid = $uid;
            return  $next($request);
        } else {
            return  responses([],'1001','请先登录');
        }
    }
}
